package ui;

/**
 * EDCStatusPanel
 * Used to show progression of the operation of analysis
 * TODO: not working for now (shows 100% once at the end), how to refresh during the process ?
 */
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import java.awt.FlowLayout;
import java.awt.Dimension;

public class EDCStatusPanel extends JPanel implements ChangeListener{

	private static final long serialVersionUID = 1L;
	private JLabel lblStatus;
	private JProgressBar progressBar;
	private FlowLayout layout;
	
	public EDCStatusPanel(){
		super();
		layout = new FlowLayout(FlowLayout.LEFT);
		setLayout(layout);
		setPreferredSize(new Dimension(800, 30));
		lblStatus = new JLabel("Status : ");
		add(lblStatus);
		progressBar = new JProgressBar(0,99);
		progressBar.setString("Progression");
		progressBar.setValue(0);
		progressBar.setStringPainted(true);
		progressBar.addChangeListener(this);
		add(progressBar);
	}
	
	public void stateChanged(ChangeEvent e){
		progressBar.setString ("Progession: " + (int)(progressBar.getPercentComplete()*100) + "%");
    }
	
	public JLabel getLabel(){
		return lblStatus;
	}
	
	public JProgressBar getProgressBar(){
		return progressBar;
	}
	
}
